package base;

/**
 * @author Seon
 * @version 1.0
 * @since 2024-09-02
 */
class CashNormal extends BaseCashStrategy {
    @Override
    public double acceptCash(double price, int count) {
        return price * count;
    }
}

class CashRebate extends BaseCashStrategy {
    private final double rebate;

    CashRebate(double rebate) {
        this.rebate = rebate;
    }

    @Override
    public double acceptCash(double price, int count) {
        return price * count * rebate;
    }
}

class CashReturn extends BaseCashStrategy {
    private final double moneyCondition;
    private final double moneyReturn;

    public CashReturn(double moneyCondition, double moneyReturn) {
        this.moneyCondition = moneyCondition;
        this.moneyReturn = moneyReturn;
    }

    @Override
    public double acceptCash(double price, int count) {
        double result = price * count;
        if (price >= moneyCondition) {
            result = price - Math.floor(result / moneyCondition) * moneyReturn;
        }
        return result;
    }
}
